package daliytool.http.server.support;

import daliytool.http.server.HttpServerHandler;
import daliytool.http.server.response.ResultObject;
import daliytool.script.FileFunctionScript;
import daliytool.service.FileService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;

/**
 * 描述 新通教育
 *
 * @author ddshuai
 * @date 2018-10-26 09:18
 **/
public class StrategyContext {
    private static final Logger logger = LoggerFactory.getLogger(StrategyContext.class);

    public static ResultObject getResponse(Map param) {

        try {
            String method = (String) param.get("method");
            if (StringUtils.isNotEmpty(method)) {
                switch (method) {
                    case "getTree":
                        return FileService.getTree(param.get("path").toString(), param.get("sys").toString());
                    case "rootPath":
                        return FileService.getRootPath();
                    case "saveHistory":
                        return FileService.saveHistory(param);
                    case "queryHistory":
                        return FileService.queryHistory();
                    default:
                        return ResultObject.getInstance();
                }
            } else {
                return ResultObject.getInstance();
            }
        } catch (Exception e) {
            logger.error("执行请求出错",e);
        }

        return ResultObject.getInstance();
    }
}
